package net.ddns.xcyyds.kungfu.procedures;

import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.Entity;
import net.minecraft.network.chat.TextComponent;

import net.ddns.xcyyds.kungfu.network.KungFuModVariables;

public class KungFuHowToUse1Procedure {
	public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
		if (entity == null)
			return;
		if ((entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new KungFuModVariables.PlayerVariables())).howToUse) {
			{
				boolean _setval = false;
				entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
					capability.howToUse = _setval;
					capability.syncPlayerVariables(entity);
				});
			}
			if (entity instanceof Player _player && !_player.level.isClientSide())
				_player.displayClientMessage(
						new TextComponent("\u4F60\u7684\u64CD\u4F5C\u65B9\u5F0F\u8BBE\u7F6E\u4E3A\u4E86\u201C\u957F\u6309\u201D"), (false));
			ForSoundProcedure.execute(world, x, y, z);
			SoundProcedure.execute(world, x, y, z, 1f, 1.5f);
		} else {
			{
				boolean _setval = true;
				entity.getCapability(KungFuModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
					capability.howToUse = _setval;
					capability.syncPlayerVariables(entity);
				});
			}
			if (entity instanceof Player _player && !_player.level.isClientSide())
				_player.displayClientMessage(
						new TextComponent("\u4F60\u7684\u64CD\u4F5C\u65B9\u5F0F\u8BBE\u7F6E\u4E3A\u4E86\u201C\u53CC\u6B21\u201D"), (false));
			ForSoundProcedure.execute(world, x, y, z);
			SoundProcedure.execute(world, x, y, z, 1f, 1.5f);
		}
	}
}
